package Year22_Month06.day17;

public class 完全二叉树的节点个数_递归写法 {
    public int countNodes(TreeNode root) {
        return DFS(root);
    }

    public int DFS(TreeNode root){
        //如果当前节点为null，那就返回0
        if(root == null) return 0;
        //不为null,就返回左右子树个数+1
        return DFS(root.left) +  DFS(root.right) + 1;
    }
}
